package com.jredu.controller.server;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.jredu.entity.User;
import com.jredu.service.UserService;

@Controller
@RequestMapping("/manager")
public class LoginController {
	@Autowired
	private UserService userService;
	@RequestMapping(value="/login",method=RequestMethod.POST)
	public String login(
			String account,
			@RequestParam(value="password") String pwd,
			HttpSession session){
		//UserService userService = new UserServiceImpl();
		User user = userService.login(account, pwd);
		if(user!=null){
			session.setAttribute("user", user);
			return "main";
		}else{
			return "redirect:/login.jsp";
		}
	}
	
	@RequestMapping("/tonav")
	public String toNavPage(){
		return "nav";
	}
}
